package inet.app.controller.parser;


import inet.app.controller.connect.JsonParser;
import inet.app.model.object.Lx_Item;

import java.util.ArrayList;

import org.json.JSONObject;

import android.util.Log;

public class Parser_Lx {


	private ArrayList<Lx_Item> list = new ArrayList<Lx_Item>();
	private Lx_Item item;
	private String ITEMS = "items";
	private String CODE = "code";
	private String NAME = "name";
	private String DATE = "date";
	private String XIEN2 = "xien2";
	private String XIEN3= "xien3";
	private String XIEN4= "xien4";
	
	public Parser_Lx () {
		
	}
	public ArrayList<Lx_Item> getList(String url) {
		list = new ArrayList<Lx_Item>();
		JSONObject jobject,object,job_items;
		JsonParser jParser = new JsonParser();
		jobject = jParser.getJSONFromUrl(url);
		try {
				String items = jobject.getString(ITEMS);
				job_items = new JSONObject(items);
				String code= job_items.getString(CODE);
				String name= job_items.getString(NAME);
				String date= job_items.getString(DATE);
				String xien2= job_items.getString(XIEN2);
				String xien3= job_items.getString(XIEN3);
				String xien4= job_items.getString(XIEN4);
				
				item = new Lx_Item(code, name, date, xien2, xien3, xien4);
				list.add(item);
				
			return list;
        } catch (Exception e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
            return null;
        }
		
	}


}
